package grafos;


import edu.uci.ics.jung.algorithms.layout.Layout;
import edu.uci.ics.jung.algorithms.layout.StaticLayout;
import edu.uci.ics.jung.graph.Graph;
import edu.uci.ics.jung.graph.SparseMultigraph;
import edu.uci.ics.jung.visualization.VisualizationViewer;
import edu.uci.ics.jung.visualization.control.EditingModalGraphMouse;
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.TextField;
import java.awt.event.*;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import org.apache.commons.collections15.Factory;

public class Tela {

    Graph<Integer, String> g;
    int nodeCount, edgeCount;
    Factory<Integer> vertexFactory;
    Factory<String> edgeFactory;
    public Painel painel;

    /**
     * Creates a new instance of SimpleGraphView
     */
    public Tela() {
        // Graph<V, E> where V is the type of the vertices and E is the type of the edges
        g = new SparseMultigraph<Integer, String>();
        nodeCount = 0;
        edgeCount = 0;
        vertexFactory = new Factory<Integer>() { // My vertex factory

            public Integer create() {
                return nodeCount++;
            }
        };
        edgeFactory = new Factory<String>() { // My edge factory

            public String create() {
                return "E" + edgeCount++;
            }
        };
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        JFrame frame = new JFrame("Grafos");
        frame.setMinimumSize(new Dimension(600,400));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        final Painel painel = new Painel();
        painel.painel();
        //painel.scrollPane.add(vv);
        frame.getContentPane().add(painel);
        frame.pack();
        frame.setVisible(true);
        frame.setBounds(100,100, 450, 450);
        frame.addWindowListener(new WindowAdapter() {

            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        
        painel.textFild.addKeyListener(new KeyListener() {

            @Override
            public void keyTyped(KeyEvent e) {
               
            }

            @Override
            public void keyPressed(KeyEvent e) {
              //  System.out.println(e.getKeyChar()+"  code"+e.getKeyCode());
              if (e.getKeyCode()==10){
                  System.out.println("teste enter");
                  if (painel.textFild.getText().matches("[[0-9]{1,2},[0-9]{1,2};]{1,30}")) {
                      System.out.println("teste matches");
                  }
            }
            }

            @Override
            public void keyReleased(KeyEvent e) {
                //System.out.println("teste");
            }
        });
    }
}
